package com.aaa.service.mht.impl;

import com.aaa.aspect.InsertAnn;
import com.aaa.aspect.UpdateAnn;
import com.aaa.dao.mht.TesterMhtDao;
import com.aaa.entity.mht.TesterMht;
import com.aaa.service.mht.TesterMhtService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


/**
 * 性格测试者(TesterMht)表服务实现类
 *
 * @author makejava
 * @since 2022-09-05 11:21:29
 */
@Service("testerMhtService")
public class TesterMhtServiceImpl implements TesterMhtService {
    @Resource
    private TesterMhtDao testerMhtDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public TesterMht queryById(Integer id) {
        return this.testerMhtDao.queryById(id);
    }

    @Override
    public TesterMht queryByPhone(String phone) {
        return testerMhtDao.queryByPhone(phone);
    }

    /**
     * 新增数据
     *
     * @param testerMht 实例对象
     * @return 实例对象
     */
    @InsertAnn
    @Override
    public TesterMht insert(TesterMht testerMht) {
        this.testerMhtDao.insert(testerMht);
        return testerMht;
    }

    /**
     * 修改数据
     *
     * @param testerMht 实例对象
     * @return 实例对象
     */
    @UpdateAnn
    @Override
    public TesterMht update(TesterMht testerMht) {
        this.testerMhtDao.update(testerMht);
        return this.queryById(testerMht.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.testerMhtDao.deleteById(id) > 0;
    }
}
